package leetcode.method.dynamic_programming;

import java.util.Arrays;

public class Program300lengthOfIncreaseSubsequence {

    public Program300lengthOfIncreaseSubsequence() {

    }
    public int lengthOfLIS(int[] nums) {
        int length = nums.length;
        if (length == 0) {
            return 0;
        }
        if (length == 1) {
            return 1;
        }
        int[] dp = new int[length];
        dp[0] = 1;
        int maxlength = 1;
        // 被记录值
        for (int i = 1; i < length; i++) {
            dp[i] = 1;
            // 比较前段所有可能性
            for (int j = 0; j < i; j++) {
                if (nums[i] > nums[j]) {
                    dp[i] = Math.max(dp[i], dp[j] + 1);
                }
            }
            maxlength = Math.max(maxlength, dp[i]);
        }
        return maxlength;
    }

    public static void main(String[] args) {
        Program300lengthOfIncreaseSubsequence myStack = new Program300lengthOfIncreaseSubsequence();
        int[] nums = {2};
        System.out.println(myStack.lengthOfLIS(nums));
    }
}
